home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / test / crshtest.c < prev    next >
Text File  |  1993-12-06  |  2KB  |  68 lines

  1. /** 
  2.  ** CRSHTEST.C 
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #include <stdlib.h>
  25. #include <string.h>
  26. #include <stdio.h>
  27.  
  28. void main(int argc,char **argv)
  29. {
  30.     char *ptr;
  31.     int  test;
  32.  
  33.     printf("Segmentation violation test for DJGPP\n");
  34.     fflush(stdout);
  35.     if((argc > 1) && (strcmp(argv[1],"-h") == 0)) {
  36.         ptr = (char *)(((int)sbrk(0) + 100000) & ~ 4095) - 1;
  37.         brk(ptr);
  38.         printf("end or RAM = 0x%08x\n",ptr);
  39.         printf("accessing *(ptr - 1) ...\n");
  40.         fflush(stdout);
  41.         test = *(ptr - 1);
  42.         printf("OK!\n");
  43.         printf("accessing *ptr ...\n");
  44.         fflush(stdout);
  45.         test = *ptr;
  46.         printf("OK!\n");
  47.         printf("accessing *(ptr + 1) ...\n");
  48.         fflush(stdout);
  49.         test = *(ptr + 1);
  50.         printf("OK!!!!!! (what ?)\n");
  51.         for( ; ; ) test = *ptr++;
  52.     }
  53.     else {
  54.         ptr = (char *)0xd0000000;
  55.         printf("start of VIDEO RAM = 0x%08x\n",ptr);
  56.         printf("accessing *ptr ...\n");
  57.         fflush(stdout);
  58.         test = *ptr;
  59.         printf("OK!\n");
  60.         printf("accessing *(ptr - 1) ...\n");
  61.         fflush(stdout);
  62.         test = *(ptr - 1);
  63.         printf("OK!!!!!! (what ?)\n");
  64.     }
  65. }
  66.  
  67.  
  68.